qui(
    function (require, exports, module) {
        VODNew.AccurateFrame = (function () {
           // var adAccurate = {};
            var openFlag = false;
            var openMode = null;
            var adAccurateFrame = {
                'head': '', //打点精确化起始帧
                'end': '', //打点精确化结束帧
                'endSetted': false,
                'headSetted': false
            }
            var params = ["fragment-l", "fragment-r", "ad-l", "ad-r",'p-r','p-l'];
            var accurateFrame = {
                'head': '', //打点精确化起始帧
                'end': '', //打点精确化结束帧
                'endSetted': false,
                'headSetted': false
            }
            //搭建js与flash互通的环境
            function thisMovie(movieName) {
                if (navigator.appName.indexOf("Microsoft") != -1) {
                    return window[movieName];
                } else {
                    return document[movieName];
                }
            }

            function doReset() {
                accurateFrame = {
                    'head': '', //打点精确化起始帧
                    'end': '', //打点精确化结束帧
                    'endSetted': false,
                    'headSetted': false
                }
            }

            function accurateStartEndRemove() {
                openFlag = false;
                var frameId = thisMovie('accurateStartEndFrame').get_select_index();

                if (frameId == -1) {
                    frameId = '';
                }
                var redParent = $('.red').parent();
                var picId = parseInt( $('.red').parent().find(".pid").text());
                if (redParent.find(".p-l").length > 0) {
                    accurateFrame.head = frameId;

                    if (accurateFrame.head){
                        accurateFrame.headSetted = true;
                        accurateFrame.headPic = picId
                    }

                }
                else if (redParent.find(".p-r").length > 0) {
                    accurateFrame.end = frameId;
                    if (accurateFrame.end){
                        accurateFrame.endSetted = true;
                        accurateFrame.endPic = picId;
                    }

                }
                else if (redParent.find(".ad-l").length > 0) {

                    adAccurateFrame.head = frameId;

                    if (adAccurateFrame.head){
                        adAccurateFrame.headSetted = true;
                        adAccurateFrame.headPic = picId
                    }
                }
                else if (redParent.find(".ad-r").length > 0) {
                    adAccurateFrame.end = frameId;
                    if (adAccurateFrame.end){
                        adAccurateFrame.endSetted = true;
                        adAccurateFrame.endPic = picId;
                    }
                }

                $('#accurateStartEndOutDiv').css({
                    'left': '-10000px',
                    'top': '-10000px'
                });
            }

            // 打点精确化数据加载
            function accurateStartEndPlay(imgSrc) {
                var analysis = VODNew.Dao.getDotData().analysis;
                $('#accurateStartEndOutDiv').css({
                    'left': '0px',
                    'top': '0px'
                });
                thisMovie('accurateStartEndFrame').change_flv_url(analysis + "?file=" + imgSrc + "&from_client=true");
                openFlag = true;
            }

            function getAccurateFrame() {
                return accurateFrame;
            }

            function updateAccurateFrame(options) {
                VODNew.Util.updateObjectData(options, accurateFrame)
            }

            function getAdAccurate() {
                return adAccurateFrame;
            }

            // has marked ad will be removed
            function adTipRemove() {
                $('.ad-l').remove();
                $('.ad-r').remove();
                adAccurateFrame = {
                    'head': '', //打点精确化起始帧
                    'end': '', //打点精确化结束帧
                    'endSetted': false,
                    'headSetted': false
                }
            }

            // has marked fragment will be removed
            function fgTipRemove() {
                $('.fragment-l').remove();
                $('.fragment-r').remove();
            }

            function handler_keyCodeQ() {
                openMode = "accurateFrame"
                var selected = $(".red").parent();
                $.each(params, function (i, element) {
                    if(selected.find("."+element).length > 0){
                        accurateStartEndPlay(selected.find("img").attr("src"));
                    }
                })
            }

            function doLastHandlerQ(){
                if( openMode == "accurateFrame"){
                    handler_keyCodeQ();
                }
            }

            function readFrameData(frameData){
                accurateFrame = $.extend(true,{},frameData);
            }
            function isDlgOpen(){
                return  openFlag;
            }

            return {
                accurateStartEndPlay: accurateStartEndPlay,
                accurateStartEndRemove: accurateStartEndRemove,
                getAccurateFrame: getAccurateFrame,
                updateAccurateFrame: updateAccurateFrame,
                getAdAccurate: getAdAccurate,
                adTipRemove: adTipRemove,
                fgTipRemove: fgTipRemove,
                handler_keyCodeQ: handler_keyCodeQ,
                doReset: doReset,
                readFrameData:readFrameData,
                isDlgOpen:isDlgOpen,
                doLastHandlerQ:doLastHandlerQ
            }
        })()
    }
);